module.exports = {
  up: async (queryInterface, Sequelize) => {
    // 给用户表添加部门字段（通过部门可以获取公司信息）
    await queryInterface.addColumn('users', 'department_id', {
      type: Sequelize.UUID,
      allowNull: true,
      references: {
        model: 'departments',
        key: 'id',
      },
      onUpdate: 'CASCADE',
      onDelete: 'SET NULL',
      comment: '所属部门ID',
    });

    // 添加索引
    await queryInterface.addIndex('users', ['department_id']);
  },

  down: async (queryInterface) => {
    await queryInterface.removeColumn('users', 'department_id');
  },
};

